/**
 * @author 小泽玛丽罗
 */
var tmpl_head='<div class="ub umh6 uinn3 ubb b-gra" style="background-color:#84ddef">'
  +'<div class="umw3 umar-a"><div class="uabs umw3 umh5" style="background-image:url(${avatar_url});border: 2em;border-color: rgb(255, 255, 255);"></div></div>'
  +'<div class="ub-f1 ub ub-ver">'
    +'<div class="ub" style="margin-top: 0.3em;">'
      +'<div class="t-blu ulev1">${nickname}</div>'
      +'<div class="umw1"></div>'
      +'<div class="ub-f1 ub">'
      	+'<div class="ub-f3">'
      		
      	+'</div>'
		+'<div class="ub-f1 tx-c t-wh" onclick="uploadPic()" style="background-color:rgb(201, 9, 9)">'
      		+'上传头像'
      	+'</div>'
      +'</div>'
      +'<div class="umw1"></div>'
    +'</div>'
   +'<div class="t-bla ulev-1 ub-f1 ub" style="margin-right: 0.2em; margin-top:0.3em;-webkit-box-orient: horizontal;">'
      +'<div class="umw2  imgBoy"></div>'
	  +'<div class="tx-l text-c ulev1">${area}  </div>'
    +'</div>'
    +'<div class="t-bla ulev-1 ub-f1 ub" style="margin-right: 0.2em; margin-top:0.3em;-webkit-box-orient: horizontal;">'
    
	  +'<div class="tx-l text-c ulev1">简介： 暂无简介<br> 标签： 暂无标签  </div>'
    +'</div>'
  +'</div>'
+'</div>'
+'<div class="ub" style="background-color:#84ddef">'
	+'<div class="ub-f1 ub ub-ver" >'
  		+'<div class="ub-f1 tx-c" style="margin-top: 0.3em;">关注</div>'
  		+'<div class="tx-c">${following_count}</div>'
	+'</div>'
	+'<div class="imgVerLine" style="min-width:0.25em"></div>'
	+'<div class="ub-f1 ub ub-ver" >'
  		+'<div class="ub-f1 tx-c" style="margin-top: 0.3em;">粉丝</div>'
  		+'<div class="tx-c">${follower_count}</div>'
	+'</div>'
	+'<div class="imgVerLine" style="min-width:0.2em"></div>'
	+'<div class="ub-f1 ub ub-ver" >'
  		+'<div class="ub-f1 tx-c" style="margin-top: 0.3em;">详细</div>'
  		+'<div class="tx-c">资料</div>'
	+'</div>'
	+'<div class="imgVerLine" style="min-width:0.25em"></div>'
	+'<div class="ub-f1 ub ub-ver" >'
  		+'<div class="ub-f1 tx-c" style="margin-top: 0.3em;">关注</div>'
  		+'<div class="tx-c">${following_count}</div>'
	+'</div>'
+'</div>'
+'<div class="min-h2 divBB mar-l5 text-c">共${weibo_count}条微博</div>';

var tmpl_forward='<div class="ub umh6 uinn3 ubb b-gra">'
  +'<div class="umw3 umar-a"><img class="uabs umw3 umh5" src="${HeadPic}"></div>'
  +'<div id="${weibo_id}" class="ub-f1 ub ub-ver">'
    +'<div class="ub" style="margin-top: 0.3em;"onclick="weiboDetail(this)">'
      +'<div class="t-blu ulev" style="font-weight:bold;">${username}</div>'
      +'<div class="umw1"></div>'
      +'<div class="ub-f1 ulev-1 tx-r t-blu">${ctime}</div>'
      +'<div class="umw1"></div>'
    +'</div>'
	+'<div class="ulev0"onclick="weiboDetail(this)" style="margin: .2em 0em .2em 0em;word-break:break-all;padding:0.8em 0em 0em 0em;">'
		+'${content}'
	+'</div>'
    +'<div class="t-bla ulev ub-f1"onclick="weiboDetail(this)" style="margin-right: 0.2em;background-color:#edeeef;word-break:break-all;padding:0.8em 0.5em 0.8em 0.5em;">'
      +'${forward_content}'
    +'</div>'
    +'<div class="t-blu ulev-1 ub umar-t" style="margin-right: 0.2em;">'
     +'<div class="ub-f1 tx-l" style="margin-top: 0.2em;">来自${source} </div><div class="ub-f1 tx-r">转播(${forward_count})|评论(${comment_count})<img id="${weibo_id}" onclick="digg(this)" src="${digg_pic}">${digg_count}</div>'
    +'</div>'
  +'</div>'
+'</div>';
var tmpl_forward_pic='<div class="ub umh6 uinn3 ubb b-gra">'
  +'<div class="umw3 umar-a"><img class="uabs umw3 umh5" src="${HeadPic}"></div>'
  +'<div id="${weibo_id}" class="ub-f1 ub ub-ver">'
    +'<div class="ub" style="margin-top: 0.3em;"onclick="weiboDetail(this)">'
      +'<div class="t-blu ulev" style="font-weight:bold;">${username}</div>'
      +'<div class="umw1"></div>'
      +'<div class="ub-f1 ulev-1 tx-r t-blu">${ctime}</div>'
      +'<div class="umw1"></div>'
    +'</div>'
	+'<div class="ulev0"onclick="weiboDetail(this)" style="margin: .2em 0em .2em 0em;word-break:break-all;padding:0.8em 0em 0em 0em;">'
		+'${content}'
	+'</div>'
   +'<div class="t-bla ulev ub ub-ver ub-f1"onclick="weiboDetail(this)" style="margin-right: 0.2em;background-color:#edeeef;word-break:break-all;padding:0.8em 0.5em 0.8em 0.5em;">'
       	  +'<div class="ub ulev-1"style="margin-right: 0.2em;background-color:#edeeef;word-break:break-all;padding:0em 0.5em 0.8em 0.2em;" >@小泽玛丽罗：转发然后输入很多子转发然后输入很多子转</div>'
	      +'<div class="ub">'
			   +'<div class=" ub-ver">'
		     	+'<div><img class="max-h3 min-w3 max-w3" src="${pic0}"></div>'
				+'<div><img class="max-h3 min-w3 max-w3" src="${pic2}"></div>'
				+'<div><img class="max-h3 min-w3 max-w3" src="${pic4}"></div>'
				+'<div><img class="max-h3 min-w3 max-w3" src="${pic6}"></div>'
		       +'</div>'
			   +'<div style="min-width:0.5em;"></div>'
			   +'<div class="ub-ver">'
		     	+'<div><img class="max-h3 min-w3 max-w3" src="${pic1}"></div>'
				+'<div><img class="max-h3 min-w3 max-w3" src="${pic3}"></div>'
				+'<div><img class="max-h3 min-w3 max-w3" src="${pic5}"></div>'
				+'<div><img class="max-h3 min-w3 max-w3" src="${pic7}"></div>'
		       +'</div>'
          +'</div>'
	+'</div>'
    +'<div class="t-blu ulev-1 ub umar-t" style="margin-right: 0.2em;">'
     +'<div class="ub-f1 tx-l" style="margin-top: 0.2em;">来自${source} </div><div class="ub-f1 tx-r">转播(${forward_count})|评论(${comment_count})<img id="${weibo_id}" onclick="digg(this)" src="${digg_pic}">${digg_count}</div>'
    +'</div>'
  +'</div>'
+'</div>';
 var tmpl_Noforward='<div class="ub umh6 uinn3 ubb b-gra">'
  +'<div class="umw3 umar-a"><img class="uabs umw3 umh5" src="${HeadPic}"></div>'
  +'<div id="${weibo_id}" class="ub-f1 ub ub-ver">'
    +'<div class="ub" style="margin-top: 0.3em;"onclick="weiboDetail(this)">'
      +'<div class="t-blu ulev" style="font-weight:bold;">${username}</div>'
      +'<div class="umw1"></div>'
      +'<div class="ub-f1 ulev-1 tx-r t-blu">${ctime}</div>'
      +'<div class="umw1"></div>'
    +'</div>'
    +'<div class="t-bla ulev ub-f1"onclick="weiboDetail(this)" style="margin-right: 0.2em;margin-top:1.5em;word-break:break-all;">'
      +'${content}'
    +'</div>'
    +'<div class="t-blu ulev-1 ub umar-t" style="margin-right: 0.2em;">'
     +'<div class="ub-f1 tx-l" style="margin-top: 0.2em;">来自${source}</div><div class="ub-f1 tx-r">转播(${forward_count})|评论(${comment_count})<img id="${weibo_id}" onclick="digg(this)" src="${digg_pic}">${digg_count}</div>'
    +'</div>'
  +'</div>'
+'</div>';


var tmpl_Noforward_Pic='<div class="ub umh6 uinn3 ubb b-gra">'
  +'<div class="umw3 umar-a"><img class="uabs umw3 umh5" src="${HeadPic}"></div>'
  +'<div id="${weibo_id}" class="ub-f1 ub ub-ver">'
    +'<div class="ub" style="margin-top: 0.3em;"onclick="weiboDetail(this)">'
      +'<div class="t-blu ulev" style="font-weight:bold;">${username}</div>'
      +'<div class="umw1"></div>'
      +'<div class="ub-f1 ulev-1 tx-r t-blu">${ctime}</div>'
      +'<div class="umw1"></div>'
    +'</div>'
	+'<div class="ulev0"onclick="weiboDetail(this)" style="margin: .2em 0em .2em 0em;word-break:break-all;padding:0.8em 0em 0em 0em;">'
		+'${content}'
	+'</div>'
    +'<div class="t-bla ulev ub ub-ver ub-f1"onclick="weiboDetail(this)" style="margin-right: 0.2em;background-color:#edeeef;word-break:break-all;padding:0.8em 0.5em 0.8em 0.5em;">'
       	  +'<div class="ub ulev-1"style="margin-right: 0.2em;background-color:#edeeef;word-break:break-all;padding:0em 0.5em 0.8em 0.2em;" >@小泽玛丽罗：转发然后输入很多子转发然后输入很多子转</div>'
	      +'<div class="ub">'
			   +'<div class=" ub-ver">'
		     	+'<div><img class="max-h3 min-w3 max-w3" src="${pic0}"></div>'
				+'<div><img class="max-h3 min-w3 max-w3" src="${pic2}"></div>'
				+'<div><img class="max-h3 min-w3 max-w3" src="${pic4}"></div>'
				+'<div><img class="max-h3 min-w3 max-w3" src="${pic6}"></div>'
		       +'</div>'
			   +'<div style="min-width:0.5em;"></div>'
			   +'<div class="ub-ver">'
		     	+'<div><img class="max-h3 min-w3 max-w3" src="${pic1}"></div>'
				+'<div><img class="max-h3 min-w3 max-w3" src="${pic3}"></div>'
				+'<div><img class="max-h3 min-w3 max-w3" src="${pic5}"></div>'
				+'<div><img class="max-h3 min-w3 max-w3" src="${pic7}"></div>'
		       +'</div>'
          +'</div>'
	+'</div>'
    +'<div class="t-blu ulev-1 ub umar-t" style="margin-right: 0.2em;">'
     +'<div class="ub-f1 tx-l" style="margin-top: 0.2em;">来自${source} </div><div class="ub-f1 tx-r">转播(${forward_count})|评论(${comment_count})<img id="${weibo_id}" onclick="digg(this)" src="${digg_pic}">${digg_count}</div>'
    +'</div>'
  +'</div>'
+'</div>';
 var tmpl_add='<div id="add" name="PerWeibo" onclick="clickAdd(this)" class="ub umh5  unn c-wh tx-c ub-ver" style="border:1px solid #c5c5c5;background-color:#ebebeb; ">'
		+'<div ontouchstart="zy_touch('+'btn-act'+')" class="btn  uinn5 uc-a t-bla">点击加载</div>'
 +'</div>';
/*界面模版*/



var url='http://www.diaoyumi.ourstu.com/api/profile/getProfile';
var url_getPerWeibo='http://www.diaoyumi.ourstu.com/api/weibo/getWeiboList';


function uploadPic(){
	uexWindow.open("uploadHeadPic",0,"uploadHeadPic.html",1,"","",0,350);
}
 function loadPerData(is_me,uid){
 	var httpID=423;
	
	uexXmlHttpMgr.onData=function (inOpCode,inStatus,inResult){
		if(inStatus=1){
			var json=eval("("+inResult+")");
			if(json["success"]){
				uexXmlHttpMgr.close(httpID);
				StitchTemplate(json);
				loadPerWeiboData(is_me,uid);
			}else{
				uexWindow.toast(1,5,json["message"],500);
			}
		}
	};
	uexXmlHttpMgr.open(httpID,'post',url,3000);
	uexXmlHttpMgr.setPostData(httpID,'0',"session_id",window.localStorage["session_id"]);
	if(is_me=="true"){
		uexXmlHttpMgr.setPostData(httpID,'0',"uid",'1');
	}else{
		uexXmlHttpMgr.setPostData(httpID,'0',"uid",uid);
	}
	
	uexXmlHttpMgr.send(httpID);
 }

 
 function StitchTemplate(json){
 	var head=document.createElement('DIV');	
	var weibo=zy_tmpl_s(tmpl_head,json.user,zy_tmpl_count(json.user));//微博详情页的头部加载		
	head.innerHTML=weibo;
	document.body.appendChild(head);
 }
 
 function loadPerWeiboData(is_me,uid){
 	var httpID=342;
	var type="PerWeibo";
	uexXmlHttpMgr.onData=function (inOpCode,inStatus,inResult){
		var json=eval("("+inResult+")");
		if(json["success"]){
			var time=TimeNow();
			//设置本次刷新时间,refreshTime+type例如refreshTimeWeibo,refreshTimeAt.refreshTimeComment ,refreshTimeCollect
			window.localStorage.setItem("refreshTime"+type,time);
			//设置本次刷新时间,offset+type例如offsetWeibo,offsetAt,offsetComment,offsetCollect
			var len=zy_tmpl_count(json["list"]);
			window.localStorage.setItem(type+"offset",len);//点击加载时从第几条开始的参数
			var i=0;
			for( i=0;i<len;i++)
			{	
				var obj=json["list"][i];
				obj=userToArt(obj,obj.user);
				//obj=UrlAdd(obj);	
				obj["ctime"]=addFriendlyTime2(obj.ctime);
				obj=WeiboJsonDataHandle(type,obj);
				json["list"][i]=obj;
			}
			window.localStorage[type+"WeiboList"]=JSON.stringify(json);//将json对象转换成json字符串保存
			//var read=window.localStorage[type+"WeiboList"];
			var add=document.createElement('DIV');
			var end=zy_tmpl_s(tmpl_add,obj,zy_tmpl_count(obj));
			add.innerHTML=end;
					
			document.body.appendChild(add);
		}else{
			uexWindow.toast(1,5,json["message"],500);
		}
	}
	uexXmlHttpMgr.open(httpID,'post',url_getPerWeibo,3000);
	if(window.localStorage["is_me"]=="true"){
		uexXmlHttpMgr.setPostData(httpID,'0',"uid",'1');
	}else{
		uexXmlHttpMgr.setPostData(httpID,'0',"uid",uid);
	}
	uexXmlHttpMgr.send(httpID);
	
 }
